--[[
    luajit C/API declaritions
]]

module(...,package.seeall)

local ffi = require("ffi")

ffi.cdef[[
	enum {
	LUA_REGISTRYINDEX =	(-10000),
	LUA_ENVIRONINDEX  =	(-10001),
	LUA_GLOBALSINDEX  =	(-10002),
	};

	typedef struct lua_State lua_State;
	typedef int64_t lua_Integer;
	lua_State* luaL_newstate(void);
	typedef int (*lua_CFunction) (lua_State *L);
	void luaL_openlibs(lua_State*);
	const char *lua_pushstring(lua_State*, const char*);
	void lua_pushinteger(lua_State*, lua_Integer);
    const char *lua_pushlstring (lua_State *L, const char *s, size_t len);

	int luaL_loadstring(lua_State*, const char*);
    int luaL_loadbuffer(lua_State *L, const char *buf, size_t size,
			       const char *name);
	int lua_pcall(lua_State *L, int nargs, int nresults, int errfunc);
	lua_Integer lua_tointeger(lua_State *L, int idx);
	void  lua_settable(lua_State *L, int idx);
	void  lua_setfield(lua_State *L, int idx, const char *k);
	void  lua_rawset(lua_State *L, int idx);
 	void  lua_rawseti(lua_State *L, int idx, int n);
 	int   lua_setmetatable(lua_State *L, int objindex);
 	int   lua_setfenv(lua_State *L, int idx);
]]

